package com.itheima.dubbo.service.impl;

import com.itheima.dubbo.pojo.User;
import com.itheima.dubbo.UserService;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.config.annotation.Method;
import org.apache.dubbo.rpc.RpcContext;

//@DubboService(timeout = 1000)//注册到注册中心，服务提供方
//@DubboService(methods = {@Method(name = "hello",timeout = 9000)})//method,方法级配置
//@DubboService(version = "1.1.0")
@DubboService
public class UserServiceImpl implements UserService {

    @Override
    public String hello(String user) {
        System.out.println("hello.......");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "user=="+user;
    }

    @Override
    public User findUser(String name) {
        User user1=new User();
        user1.setName(name);
        return user1;
    }

    @Override
    public User findOne(Long id) {
        User user = new User();
        user.setName("123");
        user.setId(id);
     /*   boolean providerSide = RpcContext.getContext().isProviderSide();
        String remoteHost = RpcContext.getContext().getRemoteHost();*/
        RpcContext.getContext().getAttachment("company");
        return user;
    }
}
